package aps

import glory.xxd.Utils
import org.json.JSONObject

/**
 * PDA操作，请求设备Ctsensor值
 */
class RequireCTsensorC2EController {

    def commentService
    /**
     * <Request>
     <Header>
     <TRANSACTIONID>9c36ccc4-b164-4fd4-8621-6fb1f9c59c1b</TRANSACTIONID>
     <MESSAGENAME>RequireCTsensorC2E</MESSAGENAME>
     <USERNAME>PDA</USERNAME>
     </Header>
     <Body class="Body">
     <EQPID>2FS07</EQPID>
     <Type>before</Type>
     </Body>
     </Request>
     *
     */
    def index() {

        def EQPID = params.EQPID ?: "1FS01"
        def Type = params.Type ?: "before"
        def MaterialPartNo = params.MaterialPartNo ?: ''
        def MaterialType = params.MaterialType ?: ''
        def SawThickness = params.SawThickness ?: ''

        def body = JSONObject.newInstance()
        body.put("EQPID", EQPID)
        body.put("Type", Type)
        body.put("MaterialPartNo", MaterialPartNo)
        body.put("MaterialType", MaterialType)
        body.put("SawThickness", SawThickness)

        String logUUID = Utils.getUUID();
        def header = JSONObject.newInstance()
        header.put("MESSAGENAME", "RequireCTsensorC2E")
        header.put("TRANSACTIONID", logUUID)
        header.put("USERNAME", 'PDA')

        def jsonAll = [Header: header, Body: body] //JSONObject.newInstance()

        def jsonRequest = JSONObject.newInstance()
        jsonRequest.put("Request", jsonAll)

        def json = commentService.getJsonByJsonForTopic2Queue(logUUID, jsonRequest)

        print json
        render json
    }
}
